1. Technical Field
The present invention relates to a method and system for data processing in general and, in particular, to a method and system for processing graphics data within a computer system. Still more particularly, the present invention relates to a method and system for performing perspective divide operations on three-dimensional graphical object data within a computer system.
2. Description of the Prior Art
Within a computer system, a three-dimensional (3-D) graphical object to be displayed on a screen of a video-display monitor is commonly built from a collection of vertices. Typically, each vertex is specified by three cartesian coordinates: x, y, and z, in a 3-D graphical object data set. Prior to display, each vertex of the graphical object has to undergo a series of transformations. The first transformation, called the modelling transformation, positions a vertex relative to a computational origin shared by all objects in a 3-D scene. The second transformation, called the viewing transformation, positions a vertex relative to the location and orientation of a viewer in front of the screen. The third transformation, called the projection transformation, accounts for optical effects such as perspective foreshortening, by positioning a vertex relative to the portion of space visible to the viewer, referred to as the view volume. The net effects of these three transformations are combined into a single transformation, which may be referred to as a vertex transformation.
Vertex transformation is performed in homogeneous coordinates in which each original vertex locations represented as a four-component vector x, y, z, 1!. This four-component vector is then multiplied by a 4.times.4 matrix, resulting in another four-component vector x', y', z', w'! that represents a vertex location relative to the view volume. The coordinates of this four-component vector are referred to as clip coordinates.
Subsequent to the vertex transformation, a so-called clip test is performed, in which each transformed vertex is checked against the boundaries of the view volume for determining whether or not the graphical object is visible to the viewer. A transformed vertex x', y', z', w'! is visible to the viewer if and only if all of the following conditions are satisfied: EQU -w'.ltoreq.x'.ltoreq.w', EQU -w'.ltoreq.y'.ltoreq.w', EQU and EQU -w'.ltoreq.z'.ltoreq.w'.
The results of these comparisons are combined to become an attribute for the vertex known as clip code. Each clip code is six-bits long, in which a "0" bit implies the corresponding inequality is satisfied while a "1" bit implies otherwise.
Each vertex that falls inside the view volume is then projected onto the screen by utilizing an operation called perspective divide. A perspective divide operation generates normalized device coordinates (NDCs) by converting a four-component clip coordinates x', y', z', w'! into a three-component NDC x'/w', y'/w', z'/w'!. In an NDC, x'/w' and y'/w' specify the horizontal and vertical location of the vertex on the screen while z'/w' represents the relative distance of the vertex from the viewer and is utilized to properly display overlapping objects. To accomplish a realistic perspective effect, the vertex transformation operates in such a manner that w' is small for points near the viewer and large for points far away from the viewer.
After the perspective divide operation, an RGBA (red, green, blue, alpha) color is further computed for each vertex based on standard lighting equations. The color is computed to simulate realistic lighting effects. Finally, the graphical object is displayed on the screen by an operation known as rasterization. This rasterization operation is frequently performed by dedicated 3-D graphics hardware, but it can also be performed by software as well.
Under the prior art, the perspective divide operation is typically performed by multiplying each of the x', y', and z' coordinates by the reciprocal of w' coordinate. Because all clip coordinates (x', y', z', w') within a 3-D graphics systems are usually represented in floating-point numbers, the perspective divide operation as performed under the prior art becomes a very expensive operation. This is due to the fact that computing the reciprocal of a floating-point number typically requires a large number of processor cycles in most, if not all, processor architectures. For example, PowerPC.TM. 604 processor manufactured by the International Business Machines Corporation requires 18 processor cycles to perform a floating-point divide operation. Furthermore, during a floating-point divide operation, a processor typically cannot execute any other floating-point operations. This is true even for a processor with multiple functional units such as the PowerPC.TM. 604 processor. In such a case, other unrelated floating-point instructions must wait until the completion of the floating-point divide operation.
Thus, each floating-point divide operation makes the perspective divide step a major bottleneck in a vertex transformation pipeline. Not to mention, a floating-point divide operation may even prevent other non-dependent operations from execution because it ties up a functional unit of the processor. Consequently, it would be desirable to provide an improved method and system for performing perspective divide operations on 3-D graphical object data within a computer system such that the burden of the perspective divide operations upon the vertex transformation pipeline can be lessened.